<?php

require_once ('../configs.php');
require_once (PASTA_SMARTY . 'Funcoes.class.php');
require_once(PASTA_BANCO_DAOGENERICO . "DaoGenerico.class.php");

$daoGenerico = new DaoGenerico();

$_GET = Funcoes::montaGetDeLinkCriptografado($_SERVER["QUERY_STRING"]);
$sql = "SELECT data_cadastro FROM tb_usuario WHERE id_usuario=" . $_GET["id"];
$data = executaGetRowEnd($sql);
$data = Funcoes::limpaDataCadastro($data);
if (Funcoes::comparaStringSensitive($_GET["dt"], $data)) {
    $sql = "UPDATE tb_usuario SET status=1 WHERE id_usuario=" . $_GET["id"];
    $rs = executaQuery($sql);
    if($rs){
        Header("Location: " . URL_FUNCAO_GET_POST."Y2xhc3NlPWV4ZWN1dGFGdW5jb2VzJmZ1bmNhbz1yZXNwb3N0YUF0aXZhQ2FkYXN0cm8mcmVzcD0x");
    }else{
        Header("Location: " . URL_FUNCAO_GET_POST."Y2xhc3NlPWV4ZWN1dGFGdW5jb2VzJmZ1bmNhbz1yZXNwb3N0YUF0aXZhQ2FkYXN0cm8mcmVzcD0w");
    }

} else {
     Header("Location: " . URL_FUNCAO_GET_POST."Y2xhc3NlPWV4ZWN1dGFGdW5jb2VzJmZ1bmNhbz1yZXNwb3N0YUF0aXZhQ2FkYXN0cm8mcmVzcD0w");
}

function getConexao() {
    $conexao = new Conexao();
    $con = $conexao->getConexao();
    return $con;
}

function executaGetRowEnd($sql) {
    $result = end(getConexao()->getRow($sql));
    getConexao()->Close();
    return $result;
}

function executaQuery($sql) {
    $result = getConexao()->Execute($sql);
    getConexao()->Close();
    return $result;
}

?>
